package org.sdv.servlet.container;

import java.util.Set;

import javax.servlet.ServletContainerInitializer;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRegistration;

import org.sdv.servlet.DivCalculationServlet;
import org.sdv.servlet.SubCalculationServlet;

public class CustomServletContainerInitializer implements ServletContainerInitializer {

	public void onStartup(Set<Class<?>> classes, ServletContext ctx)
			throws ServletException {
		System.out.println("*** CustomServletContainerInitializer ***");
		
		ServletRegistration.Dynamic registration;
		
		registration = ctx.addServlet("AddCalculation", "org.sdv.servlet.AddCalculationServlet");
		registration.addMapping("/calculator/add");
		
		registration = ctx.addServlet("SubCalculation", SubCalculationServlet.class);
		registration.addMapping("/calculator/sub");				
		
		registration = ctx.addServlet("Divcalcurator", ctx.createServlet(DivCalculationServlet.class));
		registration.addMapping("/calculator/div");
	}	
}
